<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="/admin/_layouts/default">
<head>
    <title>新增定时任务</title>
</head>
<body>
<div layout:fragment="content">

        <!-- 内容区域 -->
        <section class="content">
            <!-- Small boxes (Stat box) -->
            <div class="row">
                <div class="col-xs-12 i-navbar">
                    <a class="btn btn-primary" th:href="@{/admin/system/task/index.html}" data-pjax><i
                            class="fa fa-arrow-left"></i> 返回
                    </a>
                </div>
                <div class="col-xs-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">新增定时任务</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <form id="systemVariableForm"
                              th:action="@{/admin/system/task/insert}"
                              method="POST">
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="name">任务名称 <span class="i-label label-warning">必填</span></label>
                                    <input class="form-control" id="name" name="name"
                                           placeholder="请输入任务名称名"
                                           required
                                           type="text">
                                </div>
                                <div class="form-group">
                                    <label for="group">分组 <span class="i-label label-warning">必填</span></label>
                                    <input class="form-control" id="group" name="group"
                                           placeholder="请输入分组名称"
                                           required
                                           type="text">
                                </div>
                                <div class="form-group">
                                    <label for="execClass">执行类 <span class="i-label label-warning">必填</span></label>
                                    <input class="form-control" id="execClass" name="execClass"
                                           placeholder="请输入执行类"
                                           required
                                           type="text">
                                </div>
                                <div class="form-group">
                                    <label for="cron">定时规则 <span class="i-label label-warning">必填</span></label>
                                    <input class="form-control" id="cron" name="cron"
                                           placeholder="请输入定时规则"
                                           required
                                           type="text">
                                    <div style="width: 400px;margin-top: 10px;" class="alert alert-warning alert-dismissable">
                                        <strong>Cron示例：</strong>前后不要有空格<br>
                                        &nbsp;*/5 * * * * ?  每隔5秒执行<br>
                                        &nbsp;0 */1 * * * ?  每隔1分钟执行<br>
                                        &nbsp;0 0 23 * * ?  每天23点执行<br>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="params">设置参数及默认值 </label>
                                    <textarea class="form-control" id="params" name="params"
                                              placeholder="格式如：name=hocgin"
                                              style="height: 5em;"
                                    ></textarea>
                                    <p class="help-block">用行分割，格式如：name=hocgin</p>
                                </div>
                                <div class="form-group">
                                    <label for="description">描述</label>
                                    <textarea class="form-control" id="description" name="description"
                                              placeholder="请输入 ..."
                                              style="resize:none"
                                              rows="3"></textarea>
                                </div>
                                <div class="form-group">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" name="available"> 是否启用
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->

                            <div class="box-footer">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <!-- /.row -->
        </section>
        <!-- /内容区域 -->
        <script>
            $(function () {
                $('#systemVariableForm').ajaxForm({
                    dataType: 'json',
                    beforeSubmit: function (arr, form, option) {
                        form.find("button:submit").attr('disable', true);
                    },
                    success: function (data, statusText, xhr, form) {
                        if (data.code === 200) {
                            form.resetForm();
                            layer.msg(data.message);
                        } else {
                            layer.msg(data.message);
                        }
                        form.find("button:submit").attr('disable', false);
                    }
                })
            });
        </script>
    </div>
</body>
</html>
